from pydantic import BaseModel


class Pagination(BaseModel):
    totalRows: int
    currentPage: int
    totalPage: int
    pageSize: int
    prevPage: int | None
    nextPage: int | None


def get_pagination(page: int, page_size: int, total: int):
    total_page = total // page_size
    if total % page_size != 0:
        total_page += 1

    return Pagination(
        totalRows=total,
        currentPage=page,
        totalPage=total_page,
        pageSize=page_size,
        prevPage=page - 1 if page > 1 else None,
        nextPage=page + 1 if page < total_page else None
    )
